{% extends "base.html" %}

{% block content %}
    <div class="king-page-box">
        <div class="king-container clearfix">
            <div class="panel panel-default mb0">
                <div class="panel-heading"> 试题新增 </div>
                <div class="panel-body">
                    <form class="form-horizontal">
                        <div class="form-group clearfix f14">
                            <label class="col-sm-3 control-label bk-lh30 pt0">题目名称：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control bk-valign-top" id="ask_name" placeholder="简要描述题干信息"> </div>
                        </div>
                        <div class="form-group clearfix ">
                            <label class="col-sm-3 control-label bk-lh30 pt0">答案A：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control bk-valign-top" id="ans_A" placeholder="填写答案"> </div>
                        </div>
                        <div class="form-group clearfix ">
                            <label class="col-sm-3 control-label bk-lh30 pt0">答案B：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control bk-valign-top" id="ans_B" placeholder="填写答案"> </div>
                        </div>
                        <div class="form-group clearfix ">
                            <label class="col-sm-3 control-label bk-lh30 pt0">答案C：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control bk-valign-top" id="ans_C" placeholder="填写答案"> </div>
                        </div>
                        <div class="form-group clearfix ">
                            <label class="col-sm-3 control-label bk-lh30 pt0">答案D：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control bk-valign-top" id="ans_D" placeholder="填写答案"> </div>
                        </div>
                        <div class="form-group clearfix ">
                            <label class="col-sm-3 control-label bk-lh30 pt0">正确答案：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control bk-valign-top" id="ans_sucess" placeholder="请填写以上答案的序号（ABCD）"> </div>
                        </div>
                    </form>
                    <form class="form-horizontal">
                        <div class="form-group has-feedback clearfix ">
                            <label class="control-label col-sm-3 pt0" for="introduction">备注：</label>
                            <div class="col-sm-9">
                                <textarea class="form-control" rows="3" id="ask_info" placeholder="可填写试题的备注信息"></textarea>
                            </div>
                        </div>
                    </form>
                    <form class="form-horizontal">
                        <div class="form-group clearfix">
                            <div class="col-sm-9 col-sm-offset-3">
                                <button type="button" onclick="save_tm()" class="king-btn mr10  king-success">提交</button>
                                <a href="{{ SITE_URL }}bk_test_systerm" class="king-btn mr10  king-default" ><span>取消</span></a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
 {% block extra_block %}
<script>
        $(function(){  
                function renderTpl(str, cfg) {
                    var re = /(#(.+?)#)/g;

                    return str.replace(re, function() {
                        var val = cfg[arguments[2]]+'';
                        if(typeof val == 'undefined') {
                            val = '';
                        }
                        return val;
                    });
                }
               
            });

        function save_tm(){
            var ask_name = $('#ask_name').val();
            var ans_A = $('#ans_A').val();
            var ans_B = $('#ans_B').val();
            var ans_C = $('#ans_C').val();
            var ans_D = $('#ans_D').val();
            var ans_sucess = $('#ans_sucess').val();
            var ask_info = $('#ask_info').val();
            $.post('{{ SITE_URL }}bk_test_systerm/save_tm/', {'ask_name': ask_name, 'ans_A': ans_A, 'ans_B': ans_B, 'ans_C': ans_C, 'ans_D': ans_D, 'ans_sucess': ans_sucess, 'ask_info': ask_info}, 
            function(data){
                if(data.result){
                    alert(data.message)                    
                }else{
                    alert(data.message)
                }
            }, 'json')
            return
        }
    </script>
{% endblock %}